import { MasterPage as BaseMasterPage } from "maishu-jueying";
import { component } from "./component";
import { ValueStore } from "maishu-chitu";
import { createService, BaseComponent } from "./base-component";
import { MemberService } from "mobile/services/memberService";

@component()
export class MasterPage extends BaseMasterPage {

    style = new ValueStore<StyleColor>();

    constructor(props) {
        super(props);

        this.style.add((value) => {
            if (value == null)
                return;

            BaseComponent.loadLessFile(this, value, "components/style/baseStyle");
        })
    }

    async getStyleColor(): Promise<StyleColor> {
        if (this.style.value)
            return this.style.value;

        let member = createService(MemberService);
        let store = await member.store();//.then(store => {
        this.style.value = store.Style || "default";
        // });

        return this.style.value;
    }

}